// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "AIController.h"
#include "Q3D_CPPC_PawnState.generated.h"

class UQ3D_CPPU_PawnState;

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup = (Q3D), meta = (Tooltip = "PawnState 管理器(C++)", BlueprintSpawnableComponent))
class Q3D_LIB_API UQ3D_CPPC_PawnState : public UActorComponent
{
	GENERATED_BODY()

public:
	// Sets default values for this component's properties
	UQ3D_CPPC_PawnState();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;

public:
	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "对 PawnState 的引用"))
	UQ3D_CPPU_PawnState *Ptr_U_PawnState;

protected:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "是否需要在 Pawn 脱离 PlayerController 控制之后自动由 AIController 控制"))
	bool Bool_Config_AutoAIControllerPossessed;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "自动保存的 AIController，可复用"))
	AAIController *Ptr_A_AIController_AutoSaved;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "是否需要在当前 Pawn 脱离 PlayerController 控制之后，让 PlayerController 控制一个 SpectatorPawn"))
	bool Bool_Config_AutoSpectatorControlled;

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "自动保存的 PlayerController，如果不为空则指向控制当前 Pawn 的 PlayerController"))
	APlayerController *Ptr_A_PlayerController_Possessed;

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Q3D_PawnState, meta = (Tooltip = "自动保存的 AIController，如果不为空则指向控制当前 Pawn 的 AIController"))
	AAIController *Ptr_A_AIController_Possessed;

public:
	UFUNCTION(BlueprintCallable, Category = Q3D_PawnState, meta = (Tooltip = "在 GameState 和 PlayerState 中注册当前 Pawn/PawnState"))
	void Q3D_F_Pawn_Regist(UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PawnState, meta = (Tooltip = "在 GameState 和 PlayerState 中注销当前 Pawn/PawnState"))
	void Q3D_F_Pawn_Unregist(UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PawnState, meta = (Tooltip = "当前 Pawn 被新的 Controller 控制了"))
	void Q3D_F_Pawn_Possessed(AController *ptr_a_controller_new);

	UFUNCTION(BlueprintCallable, Category = Q3D_PawnState, meta = (Tooltip = "当前 Pawn 从某个 Controller 的控制中脱离"))
	void Q3D_F_Pawn_Unpossessed(AController *ptr_a_controller_old);
};
